﻿namespace System.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class createCommunitySystem : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.T_Activity_Registration",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ActivityID = c.Int(nullable: false),
                        UserId = c.Int(),
                        UserName = c.String(maxLength: 100, unicode: false),
                        PartakeCount = c.Int(),
                        PartakeRole = c.String(maxLength: 100, unicode: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.T_Activity_Release", t => t.ActivityID)
                .Index(t => t.ActivityID);
            
            CreateTable(
                "dbo.T_Activity_Release",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ActivityName = c.String(nullable: false, maxLength: 100, unicode: false),
                        ActivityContent = c.String(nullable: false, maxLength: 255, unicode: false),
                        ActivityTime = c.DateTime(),
                        RegistrationDeadline = c.DateTime(),
                        ActivityReward = c.String(maxLength: 255, unicode: false),
                        IsPublish = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.T_Department_Role",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        DepartmentRoleName = c.String(nullable: false, maxLength: 100, unicode: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.T_Household",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        UserName = c.String(nullable: false, maxLength: 100, unicode: false),
                        PassWord = c.String(nullable: false, maxLength: 100, unicode: false),
                        Email = c.String(maxLength: 100, unicode: false),
                        Iphone = c.String(maxLength: 13, unicode: false),
                        Sex = c.Boolean(nullable: false),
                        DepartmentRoleId = c.Int(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.T_Department_Role", t => t.DepartmentRoleId)
                .Index(t => t.DepartmentRoleId);
            
            CreateTable(
                "dbo.T_Househole_To_Storey",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        HousehoId = c.Int(nullable: false),
                        StoreyId = c.Int(nullable: false),
                        IsOwner = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.T_Household", t => t.HousehoId)
                .ForeignKey("dbo.T_Storey", t => t.StoreyId)
                .Index(t => t.HousehoId)
                .Index(t => t.StoreyId);
            
            CreateTable(
                "dbo.T_Storey",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        IssueNumber = c.String(nullable: false, maxLength: 100, unicode: false),
                        SeatNunber = c.String(nullable: false, maxLength: 100, unicode: false),
                        HoueNunber = c.String(nullable: false, maxLength: 100, unicode: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.T_Jurisdiction",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        PowerName = c.String(),
                        MenusId = c.Int(nullable: false),
                        DepartmentRoleId = c.Int(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.T_System_Menus", t => t.MenusId)
                .ForeignKey("dbo.T_Department_Role", t => t.DepartmentRoleId)
                .Index(t => t.MenusId)
                .Index(t => t.DepartmentRoleId);
            
            CreateTable(
                "dbo.T_System_Menus",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Pid = c.Int(),
                        Title = c.String(nullable: false, maxLength: 100, unicode: false),
                        Icon = c.String(nullable: false, maxLength: 100, unicode: false),
                        Href = c.String(maxLength: 100, unicode: false),
                        Target = c.String(nullable: false, maxLength: 20, unicode: false),
                        Sort = c.Int(),
                        Status = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.T_System_Menus", t => t.Pid)
                .Index(t => t.Pid);
            
            CreateTable(
                "dbo.T_Material_Maintenance",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        MateriaId = c.Int(nullable: false),
                        MaintenanceResults = c.Boolean(nullable: false),
                        MaintenanceContent = c.String(maxLength: 255, unicode: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.T_Material", t => t.MateriaId)
                .Index(t => t.MateriaId);
            
            CreateTable(
                "dbo.T_Material",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        MaterialName = c.String(nullable: false, maxLength: 100, unicode: false),
                        MaterialLocation = c.String(nullable: false, maxLength: 255, unicode: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.T_Material_Responsible",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        MaterialID = c.Int(nullable: false),
                        StaffId = c.Int(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.T_Material", t => t.MaterialID)
                .ForeignKey("dbo.T_Staff", t => t.StaffId)
                .Index(t => t.MaterialID)
                .Index(t => t.StaffId);
            
            CreateTable(
                "dbo.T_Staff",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        StaffName = c.String(nullable: false, maxLength: 100, unicode: false),
                        PassWord = c.String(nullable: false, maxLength: 100, unicode: false),
                        Email = c.String(maxLength: 100, unicode: false),
                        Iphone = c.String(maxLength: 100, unicode: false),
                        Sex = c.Boolean(nullable: false),
                        DepartmentRoleId = c.Int(nullable: false),
                        Wages = c.Double(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.T_Department_Role", t => t.DepartmentRoleId)
                .Index(t => t.DepartmentRoleId);
            
            CreateTable(
                "dbo.T_Message_Board",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        MessageText = c.String(nullable: false, maxLength: 255, unicode: false),
                        MessageName = c.String(maxLength: 100, unicode: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.T_Monitoring",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        MonitorName = c.String(nullable: false, maxLength: 100, unicode: false),
                        MonitoringArea = c.String(nullable: false, maxLength: 100, unicode: false),
                        LargeScreenSrc = c.String(nullable: false, maxLength: 255, unicode: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.T_Onlin_Survey_Result",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SurveyID = c.Int(nullable: false),
                        SurveyResult = c.Boolean(nullable: false),
                        SurveyText = c.String(maxLength: 255, unicode: false),
                        SurveyUserName = c.String(maxLength: 100, unicode: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.T_Onlin_Survey", t => t.SurveyID)
                .Index(t => t.SurveyID);
            
            CreateTable(
                "dbo.T_Onlin_Survey",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SurveyTitle = c.String(nullable: false, maxLength: 100, unicode: false),
                        SurveyContent = c.String(nullable: false, maxLength: 255, unicode: false),
                        DeadlineTime = c.DateTime(),
                        IsPublish = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.T_Parking_Deal",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Parkingid = c.Int(nullable: false),
                        SalesNature = c.Boolean(nullable: false),
                        SalesAmount = c.Double(nullable: false),
                        SalesPeople = c.String(maxLength: 100, unicode: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.T_Material", t => t.Parkingid)
                .Index(t => t.Parkingid);
            
            CreateTable(
                "dbo.T_Parking_Lot",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ParkingSpaceNumber = c.String(nullable: false, maxLength: 100, unicode: false),
                        ParkinglLocation = c.String(nullable: false, maxLength: 255, unicode: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.T_Parking_Sale",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SalesId = c.Int(nullable: false),
                        Parkingid = c.Int(nullable: false),
                        ParkingOwner = c.String(maxLength: 100, unicode: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.T_Parking_Deal", t => t.SalesId)
                .ForeignKey("dbo.T_Material", t => t.Parkingid)
                .Index(t => t.SalesId)
                .Index(t => t.Parkingid);
            
            CreateTable(
                "dbo.T_Publicity",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        PublicityName = c.String(nullable: false, maxLength: 100, unicode: false),
                        PublicityArticle = c.String(nullable: false, maxLength: 100, unicode: false),
                        ReleaseStatus = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.T_System_Setting",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SettingType = c.String(maxLength: 100, unicode: false),
                        SettingText = c.String(maxLength: 255, unicode: false),
                        SettingName = c.String(maxLength: 100, unicode: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.T_User_Guarantee",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        RepairTitle = c.String(nullable: false, maxLength: 100, unicode: false),
                        PepairContent = c.String(nullable: false, maxLength: 255, unicode: false),
                        UserId = c.Int(),
                        RepairState = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 255, unicode: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.T_Household", t => t.UserId)
                .Index(t => t.UserId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.T_User_Guarantee", "UserId", "dbo.T_Household");
            DropForeignKey("dbo.T_Parking_Sale", "Parkingid", "dbo.T_Material");
            DropForeignKey("dbo.T_Parking_Sale", "SalesId", "dbo.T_Parking_Deal");
            DropForeignKey("dbo.T_Parking_Deal", "Parkingid", "dbo.T_Material");
            DropForeignKey("dbo.T_Onlin_Survey_Result", "SurveyID", "dbo.T_Onlin_Survey");
            DropForeignKey("dbo.T_Material_Responsible", "StaffId", "dbo.T_Staff");
            DropForeignKey("dbo.T_Staff", "DepartmentRoleId", "dbo.T_Department_Role");
            DropForeignKey("dbo.T_Material_Responsible", "MaterialID", "dbo.T_Material");
            DropForeignKey("dbo.T_Material_Maintenance", "MateriaId", "dbo.T_Material");
            DropForeignKey("dbo.T_Jurisdiction", "DepartmentRoleId", "dbo.T_Department_Role");
            DropForeignKey("dbo.T_Jurisdiction", "MenusId", "dbo.T_System_Menus");
            DropForeignKey("dbo.T_System_Menus", "Pid", "dbo.T_System_Menus");
            DropForeignKey("dbo.T_Househole_To_Storey", "StoreyId", "dbo.T_Storey");
            DropForeignKey("dbo.T_Househole_To_Storey", "HousehoId", "dbo.T_Household");
            DropForeignKey("dbo.T_Household", "DepartmentRoleId", "dbo.T_Department_Role");
            DropForeignKey("dbo.T_Activity_Registration", "ActivityID", "dbo.T_Activity_Release");
            DropIndex("dbo.T_User_Guarantee", new[] { "UserId" });
            DropIndex("dbo.T_Parking_Sale", new[] { "Parkingid" });
            DropIndex("dbo.T_Parking_Sale", new[] { "SalesId" });
            DropIndex("dbo.T_Parking_Deal", new[] { "Parkingid" });
            DropIndex("dbo.T_Onlin_Survey_Result", new[] { "SurveyID" });
            DropIndex("dbo.T_Staff", new[] { "DepartmentRoleId" });
            DropIndex("dbo.T_Material_Responsible", new[] { "StaffId" });
            DropIndex("dbo.T_Material_Responsible", new[] { "MaterialID" });
            DropIndex("dbo.T_Material_Maintenance", new[] { "MateriaId" });
            DropIndex("dbo.T_System_Menus", new[] { "Pid" });
            DropIndex("dbo.T_Jurisdiction", new[] { "DepartmentRoleId" });
            DropIndex("dbo.T_Jurisdiction", new[] { "MenusId" });
            DropIndex("dbo.T_Househole_To_Storey", new[] { "StoreyId" });
            DropIndex("dbo.T_Househole_To_Storey", new[] { "HousehoId" });
            DropIndex("dbo.T_Household", new[] { "DepartmentRoleId" });
            DropIndex("dbo.T_Activity_Registration", new[] { "ActivityID" });
            DropTable("dbo.T_User_Guarantee");
            DropTable("dbo.T_System_Setting");
            DropTable("dbo.T_Publicity");
            DropTable("dbo.T_Parking_Sale");
            DropTable("dbo.T_Parking_Lot");
            DropTable("dbo.T_Parking_Deal");
            DropTable("dbo.T_Onlin_Survey");
            DropTable("dbo.T_Onlin_Survey_Result");
            DropTable("dbo.T_Monitoring");
            DropTable("dbo.T_Message_Board");
            DropTable("dbo.T_Staff");
            DropTable("dbo.T_Material_Responsible");
            DropTable("dbo.T_Material");
            DropTable("dbo.T_Material_Maintenance");
            DropTable("dbo.T_System_Menus");
            DropTable("dbo.T_Jurisdiction");
            DropTable("dbo.T_Storey");
            DropTable("dbo.T_Househole_To_Storey");
            DropTable("dbo.T_Household");
            DropTable("dbo.T_Department_Role");
            DropTable("dbo.T_Activity_Release");
            DropTable("dbo.T_Activity_Registration");
        }
    }
}
